package com.medusa.aps.business.modules.plan.mp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.medusa.aps.business.model.BaseEntity;
import com.medusa.aps.business.modules.plan.model.output.ProcessDetailsVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 工序明细实体类
 *
 * @author yuxh
 * @since 2023-08-14 17:37:48
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@Schema(description = "工序明细实体类")
public class ProcessDetails extends BaseEntity<ProcessDetails> {
    /**
     * 主键
     */
    @TableId(type = IdType.AUTO)
    @Schema(description = "主键")
    private Integer id;
    /**
     *订单id
     */
    @Schema(description = "订单id")
    private Integer orderId;
    /**
     * 订单号
     */
    @Schema(description = "订单号")
    private String orderNumber;
    /**
     * 工序号
     */
    @Schema(description = "工序号")
    private Integer processNumber;
    /**
     * 工序编码
     */
    @Schema(description = "工序编码")
    private String processCode;
    /**
     * 工序号
     */
    @Schema(description = "工序Id")
    private Integer processId;
    /**
     * 工序名称
     */
    @Schema(description = "工序名称")
    private String processName;
    /**
     * 工序描述
     */
    @Schema(description = "工序描述")
    private String processDescription;
    /**
     * 物料id
     */
    @Schema(description = "物料id")
    private Long materialId;
    /**
     * 物料编码
     */
    @Schema(description = "物料编码")
    private String materialCode;
    /**
     * 物料名称
     */
    @Schema(description = "物料名称")
    private String materialName;
    /**
     * 车间id
     */
    @Schema(description = "车间id")
    private Integer workshopId;
    /**
     * 车间编码
     */
    @Schema(description = "车间编码")
    private String workshopCode;
    /**
     * 车间名称
     */
    @Schema(description = "车间名称")
    private String workshopName;
    /**
     * 设备id
     */
    @Schema(description = "设备id")
    private Long equipmentId;
    /**
     * 设备编码
     */
    @Schema(description = "设备编码")
    private String equipmentCode;
    /**
     * 设备名称
     */
    @Schema(description = "设备名称")
    private String equipmentName;

    /**
     * 辅助资源id
     */
    @Schema(description = "辅助资源id")
    private Integer auxiliaryDataId;

    /**
     * 辅助资料编码
     */
    @Schema(description = "辅助资料编码")
    private String auxiliaryDataCoding;

    /**
     * 辅助资料名称
     */
    @Schema(description = "辅助资料名称")
    private String auxiliaryDataName;

    /**
     * 计划开始时间
     */
    @Schema(description = "计划开始时间")
    private LocalDateTime plannedStartTime;
    /**
     * 计划结束时间
     */
    @Schema(description = "计划结束时间")
    private LocalDateTime plannedEndTime;
    /**
     * 辅助资料开始时间
     */
    @Schema(description = "辅助资料开始时间")
    private LocalDateTime auxiliaryBeginTime;
    /**
     * 辅助资料结束时间
     */
    @Schema(description = "辅助资料结束时间")
    private LocalDateTime auxiliaryEndTime;
    /**
     * 需求数量
     */
    @Schema(description = "需求数量")
    private BigDecimal demandQuantity;
    /**
     * 计划数量
     */
    @Schema(description = "计划数量")
    private BigDecimal plannedQuantity;
    /**
     * 最大工序
     */
    @TableField(exist = false)
    @Schema(description = "最大工序")
    private Boolean maxProcessNumber;

    /**
     * 具体时间
     */
    private String specificTime;


    /**
     * 获取主键值
     *
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }

    public ProcessDetailsVO toProcessDetailsVO() {
        return new ProcessDetailsVO()
                .setId(id)
                .setOrderNumber(orderNumber)
                .setProcessNumber(processNumber)
                .setProcessName(processName)
                .setProcessCode(processCode)
                .setProcessDescription(processDescription)
                .setMaterialName(materialName)
                .setMaterialCode(materialCode)
                .setWorkshopName(workshopName)
                .setEquipmentName(equipmentName)
                .setEquipmentCode(equipmentCode)
                .setAuxiliaryDataName(auxiliaryDataName)
                .setAuxiliaryDataCoding(auxiliaryDataCoding)
                .setPlannedStartTime(plannedStartTime)
                .setPlannedEndTime(plannedEndTime)
                .setDemandQuantity(demandQuantity.intValue())
                .setPlannedQuantity(plannedQuantity.intValue());
    }
}

